package org.sgx.gwteditors.testgallery.gallery.yui;

import java.util.Map;

import org.sgx.gwteditors.client.editor.event.EditorValueChangeEvent;
import org.sgx.gwteditors.client.editor.event.ValueChangeListener;
import org.sgx.gwteditors.client.impl1.basetypes.InRangeDouble;
import org.sgx.gwteditors.client.util.TestUtil;
import org.sgx.gwteditors.testgallery.gallery.Test;
import org.sgx.gwteditors.testgallery.gallery.TestResources;
import org.sgx.gwteditors.yui.simple.InRangeDoubleYuiSliderEditor;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.resources.client.ExternalTextResource;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Panel;
/**
 * @author sg
 *
 */
public class YuiEditorsTest1 implements Test {

/*---begintestmaincode---*/
@Override
public void test(Panel parent) {
	parent.addStyleName("yui3-skin-sam"); 
	InRangeDouble r2 = new InRangeDouble(0.0, 1.0, 0.4);
	final InRangeDoubleYuiSliderEditor ed = new InRangeDoubleYuiSliderEditor(); 
	ed.load(r2);
	parent.add(ed.getWidget());
	ed.addValueChangeListener(new ValueChangeListener<InRangeDouble>() {
		
		@Override
		public void notifyValueChange(EditorValueChangeEvent<InRangeDouble> evt) {
			System.out.println("EVENT value change: "+evt.getSrc().flush());
		}
	}); 
	parent.add(new Button("ok", new ClickHandler() {		
		@Override
		public void onClick(ClickEvent event) {
			System.out.println(ed.flush());
		}
	})); 
}

/*---endtestmaincode---*/
	
	
	//test stuff
	@Override
	public String getName() {
		return "yuieditors1";
	}
	@Override
	public Map<String, ExternalTextResource> getJavaSources() {
		return TestUtil.getResource(getName(), TestResources.INSTANCE.BeanEditorTest1());
	}
//	@Override
//	public String[] getJavaSources() {
//		return new String[]{TestResources.INSTANCE.BeanEditorTest1().getText()};
//	}
	@Override
	public String[] getTags() {
		return new String[]{};
	}
	@Override
	public String getDescription() {
		return "show how to use BeanEditor interface so you don't have to implement PropertyHaver getProperties methods. ";
	}
}
